import React from 'react';

import BaseAction from '../common/BaseAction';
import Constants from '../../common/Constants';

export default class ActivityRequestListAction extends BaseAction {
    constructor() {
        super();

        this.moduleType = Constants.MODULE_TYPE.ACTIVITY;
        this.name = "ActivityRequestListAction";
    }

    call(caller, data) {
      this._baseCall(caller, data);
      this.caller.setState({
        viewStatus: 2,
      })
    }

    finish(data, isSucceed, response) {
      if(isSucceed) {
        let dic ={ viewStatus: 3,dataKey: data,isResponeUpdate: true,requestTag: this.data.tag,}
        let dataKey = this.data.dataKey||'data';
        dic[dataKey]=data;
        this.caller.setState(dic)
      }
      else if (data) {
        if(data.status == 401) {
          this._dealUnauthorized(this.caller);
        }
        else {
          this.caller.setState({viewStatus: data.status})
        }
      }
      else {
        this.caller.setState({viewStatus: 400})
      }
    }
}
